
#include <vfs.h>
#include <fs/filestd.h>

ceVFS* ceVFS::static_instances = 0;

ceVFS::ceVFS()
{
}

ceVFS* ceVFS::Get()
{
	if (!ceVFS::static_instances)
		{
			ceVFS::static_instances = new ceVFS ();
		}
	return ceVFS::static_instances;
}



void ceVFS::SetRootPath(const std::string &rootPath)
{
	_rootPath = rootPath;
}

ceRef<iFile> ceVFS::Open(const std::string &filename, ceOpenMode mode, ceTextMode textMode)
{
	std::string finalFilename = _rootPath + std::string("/") + filename;

	ceFileStd* file = new ceFileStd ();
	if (!file->Open(finalFilename.c_str(), mode, textMode))
		{
      delete file;
			return 0;
		}

	return file;
}


